package com.atldy.commerce.controller;

import com.atldy.commerce.account.AddressInfo;
import com.atldy.commerce.account.AddressItemVo;
import com.atldy.commerce.commence.Id;
import com.atldy.commerce.commence.TableId;
import com.atldy.commerce.service.EcommerceAddressService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @version 1.0
 * @Author: lidongyang
 * @CreateTime: 2021-08-13 0:06
 * @Description：
 */
@RestController
@Api("用户地址信息")
@RequestMapping("/address")
public class AddressController {

    @Autowired
    private EcommerceAddressService ecommerceAddressService;

    @ApiOperation("根据当前用户id获取用户地址信息列表")
    @PostMapping("/getCurrentUserAddressInfo")
    public AddressInfo getCurrentUserAddressInfo() {
        return ecommerceAddressService.getCurrentUserAddressInfo();
    }

    @ApiOperation("创建用户地址信息")
    @PostMapping("/createAddressInfo")
    public Id createAddressInfo(@RequestBody AddressItemVo addressItemVo) {
        return ecommerceAddressService.createAddressInfo(addressItemVo);
    }


    @ApiOperation("根据地址主键id获取用户地址信息")
    @PostMapping("/getAddressInfoById")
    public AddressItemVo getAddressInfoById(@RequestBody Id id) {
        return ecommerceAddressService.getAddressInfoById(id);
    }


    @ApiOperation("根据地址主键id集合获取用户地址信息列表")
    @PostMapping("/selectByUserId")
    public AddressInfo getAddressInfoByIds(TableId tableId) {
        return ecommerceAddressService.getAddressInfoByIds(tableId);
    }


}